{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "973b6c36",
   "metadata": {},
   "source": [
    "________________\n",
    "* 2022/9/19/week05\n",
    "* Python学习记录\n",
    "________________\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b90d5725",
   "metadata": {},
   "source": [
    "# 本周知识点\n",
    "\n",
    "> 1. 控制流\n",
    ">> 1. 条件判断\n",
    ">> 2. 循环遍历\n",
    "\n",
    "\n",
    "> 2. 随机函数\n",
    "\n",
    "\n",
    "> 3. 时间函数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0672fa16",
   "metadata": {},
   "source": [
    "## 1. 控制流\n",
    "### 1.1 条件判断\n",
    "\n",
    "* 知识点\n",
    "> 1. 赋值 是 “=”\n",
    "> 2. 判断是否两者相等 是 “=”\n",
    "> 3. 代码中出现的变量，必须先定义，否则： name 变量名 is not defined\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fb847881",
   "metadata": {},
   "outputs": [],
   "source": [
    "if today = \" Saturday\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5f5f0b57",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 先定义变量 today\n",
    "\n",
    "today = \"Saturday\"\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a3951e1a",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3cb1b5e5",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "249f4e27",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3df15a4a",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "46469bb1",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "beb66a34",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "147e9795",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 关于if else条件判断实践：\n",
    "## 请判断今天是周几，如果是周一，有Python课，好开心呀。如果不是，期待周一呀。（time可以帮我们知道今天周几）\n",
    "##                       如果是周一，请判断现在是否正在上Python课。 （time可以帮我们知道现在是几点钟几分钟）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "93f9c63f",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "582e8d9d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=9, tm_mday=19, tm_hour=10, tm_min=39, tm_sec=49, tm_wday=0, tm_yday=262, tm_isdst=0)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "23a3255c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    " time.localtime().tm_wday"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "3843f781",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "周几 0\n",
      "几点 11\n",
      "几分 14\n",
      "有Python课，好开心呀~\n",
      "现在是 11 点 14 分 正在上Python\n"
     ]
    }
   ],
   "source": [
    "# tm_day 0-6 0 是周一\n",
    "# 准备工作：准备所有可能用到的变量\n",
    "wday = time.localtime().tm_wday\n",
    "print(\"周几\",wday)\n",
    "today_hour = time.localtime().tm_hour\n",
    "print(\"几点\",today_hour)\n",
    "today_min = time.localtime().tm_min\n",
    "print(\"几分\",today_min)\n",
    "# 条件判断，完成：\n",
    "## 关于if else条件判断实践：\n",
    "## 请判断今天是周几，如果是周一，有Python课，好开心呀。如果不是，期待周一呀。（time可以帮我们知道今天周几）\n",
    "##                       如果是周一，请判断现在是否正在上Python课。 （time可以帮我们知道现在是几点钟几分钟）\n",
    "\n",
    "if wday == 0:\n",
    "    print(\"有Python课，好开心呀~\")\n",
    "    if 8 < today_hour < 12:\n",
    "        print(\"现在是\",today_hour,\"点\",today_min,\"分\",\"正在上Python\")\n",
    "else:\n",
    "    print(\"期待周一呀\")\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "feac8a6e",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "cdc0ce82",
   "metadata": {},
   "source": [
    "## 2. 循环遍历 (for)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "e0a73a2a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "for i in [1,2,3]:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "53910ca3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "H\n",
      "i\n",
      "!\n"
     ]
    }
   ],
   "source": [
    "for ch in \"Hi!\":\n",
    "    print(ch)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "8e5c9a0e",
   "metadata": {},
   "outputs": [],
   "source": [
    "#  上述 i  和 ch  都是变量，可以根据我们的需求定义变量名\n",
    "#  每一次执行，赋值一次"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "38c19895",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello world!\n",
      "hello world!\n",
      "hello world!\n",
      "hello world!\n",
      "hello world!\n",
      "hello world!\n",
      "hello world!\n",
      "hello world!\n",
      "hello world!\n",
      "hello world!\n"
     ]
    }
   ],
   "source": [
    "# range():范围，区间\n",
    "for run in range(10):\n",
    "        print(\"hello world!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "68ebea76",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(0, 5)"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 1. range()是一个数字/数值生成器，默认每次增加1\n",
    "# 2. range() 包含有  起始点 start (默认为0)  终结点 stop   以及步长 step (默认为1)\n",
    "\n",
    "range(5)  # 默认的起点 是 0 ，终结点 5     产生了  5 - 0 个数值，默认每次增加1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "88ce81b5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 1, 2, 3, 4]"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "c785c9e2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(5, 10)"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "range(5,10)  # 自定义起始点   5， 终结点   10      产生了  10  -  5  个数值，默认每次增加1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "e94d71a2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[5, 6, 7, 8, 9]"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(5,10))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "3145c051",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(0, 10, 3)"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "range(0,10,3)  # 自定义起始点   0， 终结点   10     自定义每次增加3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "c1006d09",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 3, 6, 9]"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(0,10,3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3c4dc50a",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 请参考以下，获取广州南方学院"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "6b10852b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https://jw.nfu.edu.cn/jwtz/index.htm0.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm1.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm2.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm3.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm4.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm5.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm6.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm7.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm8.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm9.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm10.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm11.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm12.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm13.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm14.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm15.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm16.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm17.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm18.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm19.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm20.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm21.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm22.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm23.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm24.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm25.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm26.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm27.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm28.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm29.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm30.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm31.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm32.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm33.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm34.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm35.htm\n",
      "https://jw.nfu.edu.cn/jwtz/index.htm36.htm\n"
     ]
    }
   ],
   "source": [
    "# 实践： 数据挖掘————获取页面URL队列\n",
    "学校要闻 = \"xxyw\"\n",
    "通知公告 = \"tzgg\"\n",
    "\n",
    "\n",
    "for page in range(37):\n",
    "    print(\"https://jw.nfu.edu.cn/jwtz/index.htm\" + str(page) + \".htm\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "737b9ca5",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c67ac378",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 练习，课本P4  涉及知识点：模块，变量，条件判断\n",
    "\n",
    "# 练习，课本P33  涉及知识点：模块，变量，条件判断，time模块，for循环\n",
    "\n",
    "# 练习，课本P44  涉及知识点：模块，变量，条件判断，time模块，random模块，for循环"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "8b111c5e",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Not an add minute.\n"
     ]
    }
   ],
   "source": [
    "from datetime import datetime\n",
    "\n",
    "odds = {1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59}\n",
    "\n",
    "right_this_minute = datetime.today().minute\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(\"this minute seems a little odd.\")\n",
    "else:\n",
    "    print(\"Not an add minute.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "3b3c6f82",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "not an odd minute.\n",
      "not an odd minute.\n",
      "this minute seems a little odd.\n",
      "this minute seems a little odd.\n",
      "this minute seems a little odd.\n"
     ]
    }
   ],
   "source": [
    "from datetime import datetime\n",
    "import random\n",
    "import time\n",
    "\n",
    "odds = [ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35,\n",
    "         37, 39, 41, 43, 45, 51, 53, 55, 57, 59 ]\n",
    "\n",
    "for i in range(5):\n",
    "    right_this_minute = datetime.today().minute\n",
    "    if right_this_minute in odds:\n",
    "        print(\"this minute seems a little odd.\")\n",
    "    else:\n",
    "        print(\"not an odd minute.\")\n",
    "    wait_time = random.randint(1,60)\n",
    "    time.sleep(wait_time)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "077c7549",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99 bottles of beer on the wall.\n",
      "99 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "98 bottles of beer on teh wall.\n",
      "\n",
      "98 bottles of beer on the wall.\n",
      "98 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "97 bottles of beer on teh wall.\n",
      "\n",
      "97 bottles of beer on the wall.\n",
      "97 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "96 bottles of beer on teh wall.\n",
      "\n",
      "96 bottles of beer on the wall.\n",
      "96 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "95 bottles of beer on teh wall.\n",
      "\n",
      "95 bottles of beer on the wall.\n",
      "95 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "94 bottles of beer on teh wall.\n",
      "\n",
      "94 bottles of beer on the wall.\n",
      "94 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "93 bottles of beer on teh wall.\n",
      "\n",
      "93 bottles of beer on the wall.\n",
      "93 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "92 bottles of beer on teh wall.\n",
      "\n",
      "92 bottles of beer on the wall.\n",
      "92 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "91 bottles of beer on teh wall.\n",
      "\n",
      "91 bottles of beer on the wall.\n",
      "91 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "90 bottles of beer on teh wall.\n",
      "\n",
      "90 bottles of beer on the wall.\n",
      "90 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "89 bottles of beer on teh wall.\n",
      "\n",
      "89 bottles of beer on the wall.\n",
      "89 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "88 bottles of beer on teh wall.\n",
      "\n",
      "88 bottles of beer on the wall.\n",
      "88 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "87 bottles of beer on teh wall.\n",
      "\n",
      "87 bottles of beer on the wall.\n",
      "87 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "86 bottles of beer on teh wall.\n",
      "\n",
      "86 bottles of beer on the wall.\n",
      "86 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "85 bottles of beer on teh wall.\n",
      "\n",
      "85 bottles of beer on the wall.\n",
      "85 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "84 bottles of beer on teh wall.\n",
      "\n",
      "84 bottles of beer on the wall.\n",
      "84 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "83 bottles of beer on teh wall.\n",
      "\n",
      "83 bottles of beer on the wall.\n",
      "83 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "82 bottles of beer on teh wall.\n",
      "\n",
      "82 bottles of beer on the wall.\n",
      "82 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "81 bottles of beer on teh wall.\n",
      "\n",
      "81 bottles of beer on the wall.\n",
      "81 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "80 bottles of beer on teh wall.\n",
      "\n",
      "80 bottles of beer on the wall.\n",
      "80 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "79 bottles of beer on teh wall.\n",
      "\n",
      "79 bottles of beer on the wall.\n",
      "79 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "78 bottles of beer on teh wall.\n",
      "\n",
      "78 bottles of beer on the wall.\n",
      "78 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "77 bottles of beer on teh wall.\n",
      "\n",
      "77 bottles of beer on the wall.\n",
      "77 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "76 bottles of beer on teh wall.\n",
      "\n",
      "76 bottles of beer on the wall.\n",
      "76 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "75 bottles of beer on teh wall.\n",
      "\n",
      "75 bottles of beer on the wall.\n",
      "75 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "74 bottles of beer on teh wall.\n",
      "\n",
      "74 bottles of beer on the wall.\n",
      "74 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "73 bottles of beer on teh wall.\n",
      "\n",
      "73 bottles of beer on the wall.\n",
      "73 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "72 bottles of beer on teh wall.\n",
      "\n",
      "72 bottles of beer on the wall.\n",
      "72 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "71 bottles of beer on teh wall.\n",
      "\n",
      "71 bottles of beer on the wall.\n",
      "71 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "70 bottles of beer on teh wall.\n",
      "\n",
      "70 bottles of beer on the wall.\n",
      "70 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "69 bottles of beer on teh wall.\n",
      "\n",
      "69 bottles of beer on the wall.\n",
      "69 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "68 bottles of beer on teh wall.\n",
      "\n",
      "68 bottles of beer on the wall.\n",
      "68 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "67 bottles of beer on teh wall.\n",
      "\n",
      "67 bottles of beer on the wall.\n",
      "67 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "66 bottles of beer on teh wall.\n",
      "\n",
      "66 bottles of beer on the wall.\n",
      "66 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "65 bottles of beer on teh wall.\n",
      "\n",
      "65 bottles of beer on the wall.\n",
      "65 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "64 bottles of beer on teh wall.\n",
      "\n",
      "64 bottles of beer on the wall.\n",
      "64 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "63 bottles of beer on teh wall.\n",
      "\n",
      "63 bottles of beer on the wall.\n",
      "63 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "62 bottles of beer on teh wall.\n",
      "\n",
      "62 bottles of beer on the wall.\n",
      "62 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "61 bottles of beer on teh wall.\n",
      "\n",
      "61 bottles of beer on the wall.\n",
      "61 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "60 bottles of beer on teh wall.\n",
      "\n",
      "60 bottles of beer on the wall.\n",
      "60 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "59 bottles of beer on teh wall.\n",
      "\n",
      "59 bottles of beer on the wall.\n",
      "59 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "58 bottles of beer on teh wall.\n",
      "\n",
      "58 bottles of beer on the wall.\n",
      "58 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "57 bottles of beer on teh wall.\n",
      "\n",
      "57 bottles of beer on the wall.\n",
      "57 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "56 bottles of beer on teh wall.\n",
      "\n",
      "56 bottles of beer on the wall.\n",
      "56 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "55 bottles of beer on teh wall.\n",
      "\n",
      "55 bottles of beer on the wall.\n",
      "55 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "54 bottles of beer on teh wall.\n",
      "\n",
      "54 bottles of beer on the wall.\n",
      "54 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "53 bottles of beer on teh wall.\n",
      "\n",
      "53 bottles of beer on the wall.\n",
      "53 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "52 bottles of beer on teh wall.\n",
      "\n",
      "52 bottles of beer on the wall.\n",
      "52 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "51 bottles of beer on teh wall.\n",
      "\n",
      "51 bottles of beer on the wall.\n",
      "51 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "50 bottles of beer on teh wall.\n",
      "\n",
      "50 bottles of beer on the wall.\n",
      "50 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "49 bottles of beer on teh wall.\n",
      "\n",
      "49 bottles of beer on the wall.\n",
      "49 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "48 bottles of beer on teh wall.\n",
      "\n",
      "48 bottles of beer on the wall.\n",
      "48 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "47 bottles of beer on teh wall.\n",
      "\n",
      "47 bottles of beer on the wall.\n",
      "47 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "46 bottles of beer on teh wall.\n",
      "\n",
      "46 bottles of beer on the wall.\n",
      "46 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "45 bottles of beer on teh wall.\n",
      "\n",
      "45 bottles of beer on the wall.\n",
      "45 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "44 bottles of beer on teh wall.\n",
      "\n",
      "44 bottles of beer on the wall.\n",
      "44 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "43 bottles of beer on teh wall.\n",
      "\n",
      "43 bottles of beer on the wall.\n",
      "43 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "42 bottles of beer on teh wall.\n",
      "\n",
      "42 bottles of beer on the wall.\n",
      "42 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "41 bottles of beer on teh wall.\n",
      "\n",
      "41 bottles of beer on the wall.\n",
      "41 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "40 bottles of beer on teh wall.\n",
      "\n",
      "40 bottles of beer on the wall.\n",
      "40 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "39 bottles of beer on teh wall.\n",
      "\n",
      "39 bottles of beer on the wall.\n",
      "39 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "38 bottles of beer on teh wall.\n",
      "\n",
      "38 bottles of beer on the wall.\n",
      "38 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "37 bottles of beer on teh wall.\n",
      "\n",
      "37 bottles of beer on the wall.\n",
      "37 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "36 bottles of beer on teh wall.\n",
      "\n",
      "36 bottles of beer on the wall.\n",
      "36 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "35 bottles of beer on teh wall.\n",
      "\n",
      "35 bottles of beer on the wall.\n",
      "35 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "34 bottles of beer on teh wall.\n",
      "\n",
      "34 bottles of beer on the wall.\n",
      "34 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "33 bottles of beer on teh wall.\n",
      "\n",
      "33 bottles of beer on the wall.\n",
      "33 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "32 bottles of beer on teh wall.\n",
      "\n",
      "32 bottles of beer on the wall.\n",
      "32 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "31 bottles of beer on teh wall.\n",
      "\n",
      "31 bottles of beer on the wall.\n",
      "31 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "30 bottles of beer on teh wall.\n",
      "\n",
      "30 bottles of beer on the wall.\n",
      "30 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "29 bottles of beer on teh wall.\n",
      "\n",
      "29 bottles of beer on the wall.\n",
      "29 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "28 bottles of beer on teh wall.\n",
      "\n",
      "28 bottles of beer on the wall.\n",
      "28 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "27 bottles of beer on teh wall.\n",
      "\n",
      "27 bottles of beer on the wall.\n",
      "27 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "26 bottles of beer on teh wall.\n",
      "\n",
      "26 bottles of beer on the wall.\n",
      "26 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "25 bottles of beer on teh wall.\n",
      "\n",
      "25 bottles of beer on the wall.\n",
      "25 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "24 bottles of beer on teh wall.\n",
      "\n",
      "24 bottles of beer on the wall.\n",
      "24 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "23 bottles of beer on teh wall.\n",
      "\n",
      "23 bottles of beer on the wall.\n",
      "23 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "22 bottles of beer on teh wall.\n",
      "\n",
      "22 bottles of beer on the wall.\n",
      "22 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "21 bottles of beer on teh wall.\n",
      "\n",
      "21 bottles of beer on the wall.\n",
      "21 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "20 bottles of beer on teh wall.\n",
      "\n",
      "20 bottles of beer on the wall.\n",
      "20 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "19 bottles of beer on teh wall.\n",
      "\n",
      "19 bottles of beer on the wall.\n",
      "19 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "18 bottles of beer on teh wall.\n",
      "\n",
      "18 bottles of beer on the wall.\n",
      "18 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "17 bottles of beer on teh wall.\n",
      "\n",
      "17 bottles of beer on the wall.\n",
      "17 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "16 bottles of beer on teh wall.\n",
      "\n",
      "16 bottles of beer on the wall.\n",
      "16 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "15 bottles of beer on teh wall.\n",
      "\n",
      "15 bottles of beer on the wall.\n",
      "15 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "14 bottles of beer on teh wall.\n",
      "\n",
      "14 bottles of beer on the wall.\n",
      "14 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "13 bottles of beer on teh wall.\n",
      "\n",
      "13 bottles of beer on the wall.\n",
      "13 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "12 bottles of beer on teh wall.\n",
      "\n",
      "12 bottles of beer on the wall.\n",
      "12 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "11 bottles of beer on teh wall.\n",
      "\n",
      "11 bottles of beer on the wall.\n",
      "11 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "10 bottles of beer on teh wall.\n",
      "\n",
      "10 bottles of beer on the wall.\n",
      "10 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "9 bottles of beer on teh wall.\n",
      "\n",
      "9 bottles of beer on the wall.\n",
      "9 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "8 bottles of beer on teh wall.\n",
      "\n",
      "8 bottles of beer on the wall.\n",
      "8 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "7 bottles of beer on teh wall.\n",
      "\n",
      "7 bottles of beer on the wall.\n",
      "7 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "6 bottles of beer on teh wall.\n",
      "\n",
      "6 bottles of beer on the wall.\n",
      "6 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "5 bottles of beer on teh wall.\n",
      "\n",
      "5 bottles of beer on the wall.\n",
      "5 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "4 bottles of beer on teh wall.\n",
      "\n",
      "4 bottles of beer on the wall.\n",
      "4 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "3 bottles of beer on teh wall.\n",
      "\n",
      "3 bottles of beer on the wall.\n",
      "3 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "2 bottles of beer on teh wall.\n",
      "\n",
      "2 bottles of beer on the wall.\n",
      "2 bottles of beer\n",
      "take one down\n",
      "pass it around.\n",
      "1 bottle of beer on teh wall.\n",
      "\n",
      "1 bottle of beer on the wall.\n",
      "1 bottle of beer\n",
      "take one down\n",
      "pass it around.\n",
      "no more bottle of beer on the wall.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "word = \"bottles\" \n",
    "\n",
    "for beer_num in range(99,0,-1):  \n",
    "    print(beer_num, word, \"of beer on the wall.\")\n",
    "    print(beer_num, word, \"of beer\") \n",
    "    print(\"take one down\")\n",
    "    print(\"pass it around.\") \n",
    "    if beer_num == 1:  \n",
    "        print(\"no more bottle of beer on the wall.\")\n",
    "    else:  \n",
    "        new_num = beer_num - 1\n",
    "        if new_num == 1:\n",
    "            word = \"bottle\"\n",
    "        print(new_num, word, \"of beer on teh wall.\") \n",
    "    print()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e12e70df",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
